home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-19 | 1.6 KB | 64 lines | [TEXT/KEEN] |
- # $IBM_TO_MAC: translate, sending results to new file.
- # New file name: is all lowercase version of the original
- # name - if the name of the file you'll be translating
- # has no uppercase characters, uncomment the line
- # "## newname = "_" newname # if no uppercase"
- # below or modify as you wish.
- # Translation: the input record separator RS is set
- # to a line feed ("\012"). The output separator remains
- # a carriage return ("\015"), so all line feeds are replaced by
- # carriage returns. If you have additional characters to strip,
- # uncomment and modify the "gsub" call below.
- # Input typically from "MFS selected files", output to new
- # files with similar names and same locations, with a
- # summary to stdout.
-
- BEGIN {
- u = "abcdefghijklmnopqrstuvwxyz"
- U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- RS = "\012"
- outfile = ""
- }
-
- FNR == 1 {
- beep(0)
- if (outfile != "")
- {
- close(outfile)
- namearray[++numnames] = outfile
- }
- n = split(FILENAME, names, ":")
- if (match(names[n], /;/))
- newnamet = substr(names[n], 1, RSTART-1)
- else
- newnamet = names[n]
- m = length(newnamet)
- newname = ""
- for (i = 1; i <= m; ++i)
- {
- if (ind = index(U, substr(newnamet, i, 1)))
- newname = newname substr(u, ind, 1);
- else
- newname = newname substr(newnamet, i, 1)
- }
- ## newname = "_" newname # if no uppercase
- outfile = names[1]
- for (i = 2; i < n; ++i)
- outfile = outfile ":" names[i]
- ##outfile = outfile ":" "untitled folder"
- outfile = outfile ":" newname
- }
-
- {
- ## gsub(/["\0"]/, "") # strip "reg exp", here a NULL.
- print $0 > outfile
- }
-
- END {
- namearray[++numnames] = outfile
- print "translated files:"
- for (i = 1; i <= numnames; ++i)
- print namearray[i]
- }
-
-